package com.ruoyi.web.controller.system.course.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.course.domain.ServiceCourseResPrivateTeach;
import com.ruoyi.system.course.service.IServiceCourseResPrivateTeachService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约私教记录Controller
 * 
 * @author Administrator
 * @date 2021-03-06
 */
@Controller
@RequestMapping("/course/teach")
public class ServiceCourseResPrivateTeachController extends BaseController
{
    private String prefix = "course/teach";

    @Autowired
    private IServiceCourseResPrivateTeachService serviceCourseResPrivateTeachService;

    @RequiresPermissions("course:teach:view")
    @GetMapping()
    public String teach()
    {
        return prefix + "/teach";
    }

    /**
     * 查询预约私教记录列表
     */
    @RequiresPermissions("course:teach:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ServiceCourseResPrivateTeach serviceCourseResPrivateTeach)
    {
        startPage();
        List<ServiceCourseResPrivateTeach> list = serviceCourseResPrivateTeachService.selectServiceCourseResPrivateTeachList(serviceCourseResPrivateTeach);
        return getDataTable(list);
    }

    /**
     * 导出预约私教记录列表
     */
    @RequiresPermissions("course:teach:export")
    @Log(title = "预约私教记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ServiceCourseResPrivateTeach serviceCourseResPrivateTeach)
    {
        List<ServiceCourseResPrivateTeach> list = serviceCourseResPrivateTeachService.selectServiceCourseResPrivateTeachList(serviceCourseResPrivateTeach);
        ExcelUtil<ServiceCourseResPrivateTeach> util = new ExcelUtil<ServiceCourseResPrivateTeach>(ServiceCourseResPrivateTeach.class);
        return util.exportExcel(list, "teach");
    }

    /**
     * 新增预约私教记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存预约私教记录
     */
    @RequiresPermissions("course:teach:add")
    @Log(title = "预约私教记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ServiceCourseResPrivateTeach serviceCourseResPrivateTeach)
    {
        return toAjax(serviceCourseResPrivateTeachService.insertServiceCourseResPrivateTeach(serviceCourseResPrivateTeach));
    }

    /**
     * 修改预约私教记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ServiceCourseResPrivateTeach serviceCourseResPrivateTeach = serviceCourseResPrivateTeachService.selectServiceCourseResPrivateTeachById(id);
        mmap.put("serviceCourseResPrivateTeach", serviceCourseResPrivateTeach);
        return prefix + "/edit";
    }

    /**
     * 修改保存预约私教记录
     */
    @RequiresPermissions("course:teach:edit")
    @Log(title = "预约私教记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ServiceCourseResPrivateTeach serviceCourseResPrivateTeach)
    {
        return toAjax(serviceCourseResPrivateTeachService.updateServiceCourseResPrivateTeach(serviceCourseResPrivateTeach));
    }

    /**
     * 删除预约私教记录
     */
    @RequiresPermissions("course:teach:remove")
    @Log(title = "预约私教记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(serviceCourseResPrivateTeachService.deleteServiceCourseResPrivateTeachByIds(ids));
    }
}
